package com.h3c.nem.controller;

import com.eos.common.constant.StatusCodeEnum;
import com.eos.common.util.Result;
import com.h3c.nem.dto.TbOfferLanguageDTO;
import com.h3c.nem.service.ITbOfferLanguageService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 语言能力控制层
 *
 * @author chenyifan
 * @since 2022-06-17 11:31:11
 */
@RestController
@AllArgsConstructor
@RequestMapping("/tbOfferLanguage")
public class TbOfferLanguageController {
    /**
     * 服务对象
     */
    private final ITbOfferLanguageService tbOfferLanguageService;

    /**
     * 保存外语能力
     *
     * @param languageDTOS
     * @return
     */
    @PostMapping("/saveOfferLanguage")
    public Result<String> saveOfferLanguage(@RequestBody List<TbOfferLanguageDTO> languageDTOS) {

        try {
            tbOfferLanguageService.saveOfferLanguage(languageDTOS);
            return new Result(true, StatusCodeEnum.NORMAL);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, StatusCodeEnum.ADD_FAIl);
        }
    }

    /**
     * 回显外语能力
     *
     * @param
     * @return
     */
    @GetMapping("/showOfferLanguage")
    public Result<String> showOfferLanguage() {
        try {
            return new Result(true, StatusCodeEnum.NORMAL, tbOfferLanguageService.showOfferLanguage());
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, 400, e.getMessage());
        }
    }

}

